# coding=utf-8
"""
    users service
"""

from utils.conf_util import conf_handler


# @Time    :  2024-10-18 10:11:33
# @Author  :  jiangtong
# @Email   :  gingerqgyy@outlook.com
# @Project :  ginger_yl_test_boost
# @File    :  users


# 获取用户列表 :
def list_user():
    users = conf_handler.get('users')
    return users


# 用户登录 :
def login_user(account, pwd):
    users = list_user()
    user_accounts = [user.get('account') for user in users]
    if account not in user_accounts:
        return False, '用户不存在'
    account_index = user_accounts.index(account)
    user_info = users[account_index]
    user_pwd = user_info.get('pwd')
    if pwd != user_pwd:
        return False, '用户名或密码有误'
    return True, '登录成功'
